package com.xjtu.se.homework.ops.faq.dao;

import com.xjtu.se.homework.ops.faq.dto.FaqDto;
import com.xjtu.se.homework.ops.faq.dto.SearchDto;
import com.xjtu.se.homework.ops.faq.dto.delDto;
import com.xjtu.se.homework.ops.faq.dto.pubDto;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface FaqDao {
    List<FaqDto> showAll(FaqDto dto);

    @Insert("insert into faq(adm_id,ques_id,ques_desc,answer,status)values(#{adm_id},#{ques_id},#{ques_desc},#{answer},#{status})")
    void addFaq(FaqDto dto);

    @Update("update faq set ques_desc=#{ques_desc},answer=#{answer} where ques_id=#{ques_id}")
    void faqUpd(FaqDto dto);


    @Select("select * from faq where ques_desc LIKE concat('%',#{ques_desc},'%') ")
    List<FaqDto> searchFaq(SearchDto dto);

    @Delete("delete  from faq where ques_id=#{ques_id} ")
    int faqDel(delDto dto);

    @Update("update faq set status=#{status} where ques_id=#{ques_id}")
    void pubFaq(pubDto dto);
    @Update("update faq set status=#{status} where ques_id=#{ques_id}")
    void depubFaq(pubDto dto);


}
